<script type="text/javascript" >
    stSocialMediaToolbox.sortColumn();
    stSocialMediaToolbox.shortAction();
</script>
<div class="w100p bgl">
    <div class="w100p bgr">
        <div class="inner_container">
            <div style="float: left">
                <?php _e('Server current time', $config['plugin_name'])?>:
                <?php echo date_i18n('Y-m-d H:i:s')?>
            </div>
            <div class="filter">

                <label><?php _e('Filter by : ', $config['plugin_name']) ?></label>
                <select id="username"
                        onchange="
                            var data_post = new Array();
                            data_post['username'] = jQuery(this).val();
                            data_post['ip'] = jQuery('#ip').val();
                            data_post['browser'] = jQuery('#browser').val();
                            data_post['os'] = jQuery('#os').val();
                            data_post['status'] = jQuery('#status').val();
                            stSocialMediaToolbox.loadPage('<?php echo $current_action?>', data_post, false);
                        "
                >
                    <option value="all">username</option>
                    <?php
                   foreach($username as $value) {
                    ?>
                        <option value="<?php echo $value->username; ?>" <?php if($user == $value->username){echo 'selected';}?>><?php echo $value->username; ?></option>
                    <?php
                    }
                    ?>
                </select>
                <select id="ip"
                        onchange="
                            var data_post = new Array();
                            data_post['ip'] = jQuery(this).val();
                            data_post['username'] = jQuery('#username').val();
                            data_post['browser'] = jQuery('#browser').val();
                            data_post['os'] = jQuery('#os').val();
                            data_post['status'] = jQuery('#status').val();
                            stSocialMediaToolbox.loadPage('<?php echo $current_action?>', data_post, false);
                        "
                >
                    <option value="all">IP</option>
                    <?php
                   foreach($ip as $value) {
                    ?>
                        <option value="<?php echo $value->ip; ?>" <?php if($user_ip == $value->ip){echo 'selected';}?>><?php echo $value->ip; ?></option>
                    <?php
                    }
                    ?>
                </select>
                <select id="browser"
                        onchange="
                            var data_post = new Array();
                            data_post['browser'] = jQuery(this).val();
                            data_post['username'] = jQuery('#username').val();
                            data_post['ip'] = jQuery('#ip').val();
                            data_post['os'] = jQuery('#os').val();
                            data_post['status'] = jQuery('#status').val();
                            stSocialMediaToolbox.loadPage('<?php echo $current_action?>', data_post, false);
                        "
                >
                    <option value="all">browser</option>
                    <?php
                   foreach($browser as $value) {
                    ?>
                        <option value="<?php echo $value->browser; ?>" <?php if($user_browser == $value->browser){echo 'selected';}?>><?php echo $value->browser; ?></option>
                    <?php
                    }
                    ?>
                </select>
                <select id="os"
                        onchange="
                            var data_post = new Array();
                            data_post['os'] = jQuery(this).val();
                            data_post['browser'] = jQuery('#browser').val();
                            data_post['username'] = jQuery('#username').val();
                            data_post['ip'] = jQuery('#ip').val();
                            data_post['status'] = jQuery('#status').val();
                            stSocialMediaToolbox.loadPage('<?php echo $current_action?>', data_post, false);
                        "
                >
                    <option value="all">OS</option>
                    <?php
                   foreach($os as $value) {
                    ?>
                        <option value="<?php echo $value->os; ?>" <?php if($user_os == $value->os){echo 'selected';}?> ><?php echo $value->os; ?></option>
                    <?php
                    }
                    ?>
                </select>
                <select id="status"
                        onchange="
                            var data_post = new Array();
                            data_post['status'] = jQuery(this).val();
                            data_post['browser'] = jQuery('#browser').val();
                            data_post['username'] = jQuery('#username').val();
                            data_post['ip'] = jQuery('#ip').val();
                            data_post['os'] = jQuery('#os').val();
                            stSocialMediaToolbox.loadPage('<?php echo $current_action?>', data_post, false);
                        "
                >
                    <option value="all">Status all</option>
                    <option <?php if('1' == $status){echo 'selected';}?> value="1">Success</option>
                    <option <?php if('0' == $status){echo 'selected';}?> value="0">Fail</option>
                    
                </select>
                <br clear="both" />
            </div>
            <br clear="both" />
            <br />
            <table class="widefat" cellspacing="0">
                <thead>
                    <tr>
                        <?php print_column_headers('stSocialMediaToolbox_st_cronjob_log'); ?>
                    </tr>
                </thead>

                <tbody>
                <?php
                if (count($results) > 0) {
                    $tr_class = "";
                    $upload_data = wp_upload_dir();
                    foreach ($results as $result) {
                        if( empty($tr_class) || $tr_class == "class='bg_gray2'"){
                            $tr_class = "class='bg_gray1'";
                        }else{
                            $tr_class = "class='bg_gray2'";
                        }
                        switch ($result->status) {
                            case 1:
                                $status = __('Success', $config['plugin_name']);
                                break;
                            default:
                                $status = __('Fail', $config['plugin_name']);
                                break;
                        }
                        $date = explode(' ', $result->date);
                        $date1 = explode('-',$date[0]);
                        $date = $date1[2].'.'.$date1[1].'.'.$date1[0].' '. $date[1];
                        
                        echo "<tr id='$result->id' $tr_class >"
                        . "<td>" . $date
                        . "<div class=\"row-actions short_action\">"
//                        . "<span class='edit' action='stSocialMediaToolboxEdit' short_action='' id='$result->id'>Edit | </span>"
                        . "<span class='trash' short_action='delete' id='$result->id' confirm='Are you sure you want to delete this user log?'>Trash </span>"
                        . "</div>"
                        . "</td>"
                        . "<td>" . $result->ip . "</td>"
                        . "<td>" . $result->username . "</td>"
                        . "<td>" . $result->browser . "</td>"
                        . "<td>" . $result->os . "</td>"
                        . "<td>" . $status . "</td>"
//                      . "<div class=\"short_action\">"
//                        . "<span action='stSocialMediaToolboxEdit' short_action='' id='$result->id' ><img src=\"{$config['imagesUrl']}edit_icon.png\" alt=\"\" /></span>"
//                        //. "<span><img src=\"{$config['imagesUrl']}unapprove_icon.png\" alt=\"\" /></span>"
//                        . "<span class='trash' short_action='delete' id='$result->id' confirm='<strong>Warning!</strong>Are you sure you want to delete this stSocialMediaToolbox?' ><img src=\"{$config['imagesUrl']}bin_icon.png\" alt=\"\" /></span>"
//                        . "</div>"
//                        . "</td>"
                        . "</tr>"
                        ;
                    }
                }
                ?>
                </tbody>
            </table>
            <div class="page_d">
                <?php echo $pagination?>
                <div class="cl"></div>
            </div>

        </div>
    </div>
</div>